package com.study.util.treeutil;

import java.util.HashMap;
import java.util.List;

public class TreeNodeMap extends HashMap<String, Object> {
	/**
	 * 
	 */
	private static final long serialVersionUID = 8711412635283719860L;

	private TreeNodeConfig treeNodeConfig;

	public TreeNodeMap() {
		this.treeNodeConfig = TreeNodeConfig.getDefaultConfig();
	}

	public TreeNodeMap(TreeNodeConfig treeNodeConfig) {
		this.treeNodeConfig = treeNodeConfig;
	}

	public <T> T getId() {
		return (T) super.get(treeNodeConfig.getIdKey());
	}

	public void setId(String id) {
		super.put(treeNodeConfig.getIdKey(), id);
	}

	public <T> T getParentId() {
		return (T) super.get(treeNodeConfig.getParentIdKey());
	}

	public void setParentId(String parentId) {
		super.put(treeNodeConfig.getParentIdKey(), parentId);
	}

	public <T> T getName() {
		return (T) super.get(treeNodeConfig.getNameKey());
	}

	public void setName(String name) {
		super.put(treeNodeConfig.getNameKey(), name);
	}

	public <T> T getCode() {
		return (T) super.get(treeNodeConfig.getCodeKey());
	}

	public TreeNodeMap setCode(String code) {
		super.put(treeNodeConfig.getCodeKey(), code);
		return this;
	}

	public List<TreeNodeMap> getChildren() {
		return (List<TreeNodeMap>) super.get(treeNodeConfig.getChildrenKey());
	}

	public void setChildren(List<TreeNodeMap> children) {
		super.put(treeNodeConfig.getChildrenKey(), children);
	}

	public void extra(String key, Object value) {
		super.put(key, value);
	}

}
